package com.xgzit.xgzmall.product.web;

import com.xgzit.xgzmall.product.service.SkuInfoService;
import com.xgzit.xgzmall.product.vo.SkuItemVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * 详商品情
 * @Author xgz
 * @Date 2021-05-18 19:14
 */

// 因为是页面跳转，所有直接是Controller而不是RestController
@Controller
@Slf4j
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;

    /**
     * 展示当前sku详情
     **/
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) throws Exception {
        log.info("准备跳转查询"+skuId+"详情");
        SkuItemVo vo = skuInfoService.item(skuId);
        model.addAttribute("item", vo);
        return "item";
    }
}
